utils:::menuInstallPkgs()
utils:::menuInstallPkgs()
q()
conf=.95
title="Party Support and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")
# Get coefficients of variables
beta_1 =   .6548065
beta_3 =   -1.301007
# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)
# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2
# Compute variances
var_1 =     .09782269       + (x_2^2)*  .27669795   + 2*x_2*  -.1018895
# Standard errors
se_1 = se_1 = sqrt(var_1)
# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1
# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)
# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")
# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)
# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")
# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)
# Add a dashed horizontal line for zero
abline(h=0, lty=3)
conf=.95
title="Central-East Region and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")
# Get coefficients of variables
beta_1 =  -.6253318
beta_3 =   1.737754
# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)
# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2
# Compute variances
var_1 =     .14298761       + (x_2^2)*  .38785513    + 2*x_2* -.1683246
# Standard errors
se_1 = se_1 = sqrt(var_1)
# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1
# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)
# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")
# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)
# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")
# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)
# Add a dashed horizontal line for zero
abline(h=0, lty=3)
install.packages("gtExtras")
install.packages("gtExtras")
install.packages("gt")
install.packages("gt")
library(gtExtras)
library(gt)
library(gtExtras)
library(gt)
library(gtExtras)
library(gt)
library(gtExtras)
library(gt)
library(foreign)
library(readstata13)
library(list)
library(tidyverse)
library(ggthemes) #themes for plotting
library(sandwich) #robust se estimator
library(lmtest) #lm functions
library(ordinal) #ologit funcitons
library(memisc) #import stata data
library(ggmap) #make nice plots with ggplot mapping
library(ggplot2) #nice plots
library(Hmisc) #multipurpose package
library(RColorBrewer) #make nice colors
library(grid) #plotting package
library(MASS) #multipurpose package
library(gplots) #nice plotting
library(lfe) #run linear fixed effects models
library(stargazer) #output nice tables
library(lubridate) #deal with dates
library(zoo) #deal with dates
library(reshape2) #powerful reshape package
library(sp) #general spatial class package
library(gstat) #geostat package
library(spacetime) #store data in proper spatial/temporal class
library(rgeos)
library(maptools) #plot and modify shapefiles
library(rgeos) #for use with maptools for shapefiles
library(rgdal) #for reading in shapefiles
library(RSAGA) #needed for spatial downscaling
library(RCurl) #also needed for spatial downscaling
library(dplyr) #for data frame manipulation functions
library(data.table) #for data.table functions
library(foreign) #for reading in .dta files
library(parallel) #for parallel processing functions
library(foreach) #for plyr parallel
library(caTools) #functions for fast running mean and sd
library(ncdf4) #tools for netCDF packages
library(stringr) #string tools
library(kfigr) #figure referencing for markdown
library(knitr) #knitting
library(pander) #pandering
library(geosphere) #distance tools
library(Rcpp) #C++ tools
library(RcppArmadillo) #C++ tools
library(viridis) # color map
library(multiwayvcov) # multiway clustered standard errors for lm
library(gtable) # for switching facet labels in ggplot
library(matrixStats) # for rowMins function
library(readstata13) # read in newer stata files
library(ggExtra) # for marginal histograms
library(gridExtra) # for multiplots
library(sf)
sessionInfo()
ls()
install.packages("terra")
install.packages("raster")
unlink(".Rdata")
unlink(".Rdata")
unlink(".Rdata")
install.packages("pkgbuild")
pkgbuild::check_build_tools()
library(foreign)
library(readstata13)
library(list)
library(tidyverse)
library(ggthemes) #themes for plotting
library(sandwich) #robust se estimator
library(lmtest) #lm functions
library(ordinal) #ologit funcitons
library(memisc) #import stata data
library(ggmap) #make nice plots with ggplot mapping
library(ggplot2) #nice plots
library(Hmisc) #multipurpose package
library(RColorBrewer) #make nice colors
library(grid) #plotting package
library(MASS) #multipurpose package
library(gplots) #nice plotting
library(lfe) #run linear fixed effects models
library(stargazer) #output nice tables
library(lubridate) #deal with dates
library(zoo) #deal with dates
library(reshape2) #powerful reshape package
library(sp) #general spatial class package
library(gstat) #geostat package
library(spacetime) #store data in proper spatial/temporal class
library(rgeos)
library(maptools) #plot and modify shapefiles
library(rgeos) #for use with maptools for shapefiles
library(rgdal) #for reading in shapefiles
library(RSAGA) #needed for spatial downscaling
library(RCurl) #also needed for spatial downscaling
library(dplyr) #for data frame manipulation functions
library(data.table) #for data.table functions
library(foreign) #for reading in .dta files
library(parallel) #for parallel processing functions
library(foreach) #for plyr parallel
library(caTools) #functions for fast running mean and sd
library(ncdf4) #tools for netCDF packages
library(stringr) #string tools
library(kfigr) #figure referencing for markdown
library(knitr) #knitting
library(pander) #pandering
library(geosphere) #distance tools
library(Rcpp) #C++ tools
library(RcppArmadillo) #C++ tools
library(viridis) # color map
library(multiwayvcov) # multiway clustered standard errors for lm
library(gtable) # for switching facet labels in ggplot
library(matrixStats) # for rowMins function
library(readstata13) # read in newer stata files
library(ggExtra) # for marginal histograms
library(gridExtra) # for multiplots
library(sf)
setwd("C:/Users/kash8/OneDrive/Documents/GIS/Koos and Neupert-Wentz JCR Replication/kash2022_rap_forthcoming_replication")
acled<-readOGR(dsn="Shapefiles", layer="acled_marshall_spatial_join")
ged<-readOGR(dsn="Shapefiles", layer="ged_marshall_spatial_join")
marshall<-readOGR(dsn="Shapefiles", layer="borders_tribes805")
buffer_knw<-readOGR(dsn="Shapefiles", layer="buffer50")
acled@proj4string
proj4string(buffer_knw) <- CRS("+proj=longlat +datum=WGS84 +no_def")
match_bufferPoints <- over(acled, buffer_knw) #Assigns a signle buffer to points
match_bufferPoints <- na.omit(match_bufferPoints$NAME)
match_bufferPoints2 <- over(ged, buffer_knw) #Assigns a signle buffer to points
match_bufferPoints2 <- na.omit(match_bufferPoints2$NAME)
dissolve<- gUnaryUnion(buffer_knw)
buffer_new <- gIntersection(marshall, dissolve, byid = TRUE)
plot(buffer_new)
match_bufferPoints3 <- over(acled, buffer_new) #Assigns a signle buffer to points
match_bufferPoint3 <- na.omit(match_bufferPoints3$NAME)
View(buffer_new)
View(dissolve)
plot(dissolve)
View(buffer_new)
#################################
require(devtools)
install_version("terra", version = "1.5-12", repos = "https://cran.r-project.org/src/contrib/Archive/terra/terra_1.5-12.tar.gz")
remove.packages("raster")
remove.packages(raster)
remove.packages(terra)
remove.packages("terra")
unlink(".Rdata")
